import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3

CusWindowMask {
    id: cusPromptDialogRoot
    property alias title: win.title
    property string descrition: "Non"
    property string forgetItText: TransText.app_Cancel
    property string doSomethingText: TransText.app_OK
    property alias cancelBtnAlias: cancelBtn
    property bool _needCancelBtn: true
    property bool ok_doing: false

    signal doSomething()
    signal closeBtnClicked()


    CusWindow_w {
        id: win
        width: 460
        height: 200
        title: "Non"
        anchors.centerIn: parent
        onClose: { cusPromptDialogRoot.close(); closeBtnClicked() ; }

        Rectangle {
            id: contentBgRect
            color: "transparent"
            anchors.fill: parent
            anchors.topMargin: win.titleHeight

            Rectangle {
                id: contentRect
                anchors.top: parent.top
                anchors.bottom: statusBarRect.top
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.margins: 20

                CusText {
                    text: descrition
                    color: Theme.text_color

                    font.pixelSize: Theme.font_size_13
                    anchors.left: parent.left
                    anchors.right: parent.right
                    anchors.top: parent.top
                    wrapMode: Text.WordWrap
                }
            }

            Rectangle {
                id: statusBarRect
                color: "transparent"
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                anchors.bottomMargin: win.windowRadius
                implicitHeight: 30

                CusSolidBtn {
                    id: okBtn
                    anchors.right: parent.right
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.rightMargin: 20
                    implicitWidth: 96
                    implicitHeight: 30
                    _text: ok_doing ? "" : doSomethingText
                    onClicked: { doSomething(); }

                    AnimatedImage  {
                        anchors.centerIn: parent
                        source: "qrc:/assets/myfilelist/add_printer_loading_32x32.gif"
                        visible: ok_doing
                    }
                }

                CusHollowBtn {
                    id: cancelBtn
                    anchors.right: okBtn.left
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.rightMargin: 20
                    implicitWidth: 96
                    implicitHeight: 30
                    _text: forgetItText
                    visible: _needCancelBtn
                    onClicked: { close() }
                }
            }
        }
    }
}


